﻿/*
 *  Copyright (c) 2010, Steven Wang
 *  
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *  
 *      http://www.apache.org/licenses/LICENSE-2.0
 *      
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  
 *  twitterSina at http://twitterSina.appspot.com
 *  twitterSina code at http://twitterSina.googlecode.com
 * 	
 */
package twitterSina.servlet.cron;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import twitterSina.persistence.UserDao;
import twitterSina.persistence.SysStatusDao;
import twitterSina.persistence.SysStatus;

/**
 * 更新系统状态的Servlet
 * @author Steven Wang <http://blog.stevenwang.name>
 */
public class SysStatusServlet extends HttpServlet 
{
	private static final long serialVersionUID = 7519321168960963936L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		SysStatus sysStatus = new SysStatus();
		sysStatus.setOnlineCount(UserDao.getInstance().getOnlineUserCount());
		SysStatusDao.getInstance().addOrUpdateSysStatus(sysStatus);
	}
}
